<%@page import="org.jeecgframework.web.util.StaticValue"%>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>生成巡检计划</title>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<script type="text/javascript" src="plug-in/ckfinder/ckfinder.js"></script>
<script type="text/javascript">
$(function(){
	$("select[name='company']").change(function(){
		if($(this,"option:selected").val() != ""){
			$.ajax({
				url : "zyCommonController.do?queryTPServerBusinessr",
				data : {
					"orgCode" : $(this).val(),
					"contactPosition" : '<%=StaticValue.DIC_CONTACT_POSITION_TP_SERVER_BUSINESSR%>'
					},
				cache : false,
				dataType : 'json',
				type : 'POST',
				success : function(data){
					if(data.success){
						var obj = data.obj[0];
						if(obj){
							setContacter(obj.id, obj.name, obj.cellphone1 + (obj.cellphone2==""?"":("/"+obj.cellphone2)),obj.email);
						}else{
							setContacter();
						}
					}
				}
			});
		}else{
			setContacter();
		}
	});
	selectCurrMonth();
	$("select[name='ipMonth']").on('change',function(){
			console.log("$(this).val()"+$(this).val());
		if(parseInt($(this).val()) < parseInt('${currMonth}')){
			console.log('${currMonth}');
			selectCurrMonth();
			tip("所选月份不应小于当前月,已置为当前月份");
		}
	});
	$("#subForm").click(function(){
		$.dialog.confirm("确认保存巡检计划吗？",function(r){
			if(r){
				_form.submitForm(false,"zyInspectionPlanController.do?doAdd&zyIpId=${zyIP.id}");
			}
		});
	});
	$("#cancelPlan").click(function(){
		createwindow("取消巡检计划","zyInspectionPlanController.do?goCancelIP&id=${zyIP.id}",500,200);
		
	});
	function selectCurrMonth(){
		$("select[name='ipMonth']").find("option[value='"+'${currMonth}'+"']").attr("selected","selected");
	}
});
function callback(data){
	var curTabTitle = "新建巡检计划";
	if('${zyIP.state}' == '<%=StaticValue.DIC_PLAN_STATE_THIRDPARTY_REFUSED%>'){
		curTabTitle = "巡检计划详情";
	}
	if(data.success){
		window.top.$("#maintabs").tabs({
			title : curTabTitle,
			onBeforeClose : function(title,index){
				try {
					var tabTitle = "生成巡检计划";
					if('${parentId}' != undefined && '${parentId}' != ''){
						tabTitle = "商务分配巡检计划";
					}
					if('${zyIP.state}' == '<%=StaticValue.DIC_PLAN_STATE_THIRDPARTY_REFUSED%>'){ //如果是第三方拒绝之后修改
						tabTitle = "巡检计划管理";
					}
					window.top.$("#maintabs").tabs('select',tabTitle);
					window.top.tip(data.msg);
					if(getMainTabWin(tabTitle)){
						getMainTabWin(tabTitle).reloadTable();
					}
				} catch (e) {
				} finally{
					return true;
				}
			}
		});
		window.top.$("#maintabs").tabs('close',curTabTitle);
	}else{
		tip(data.msg);
	}
}
function setContacter(id,name,cellPhone,email){
	if(id == undefined || id == ""){
		$("#contacterId").val("");
		$("#contacterName").val("");
		$("#contacterCellPhone").html("");
		$("#contacterEmail").html("");
	}else{
		$("#contacterId").val(id);
		$("#contacterName").val(name);
		$("#contacterCellPhone").html(cellPhone);
		$("#contacterEmail").html(email);
	}
}
</script>
</head>
<body>
<t:formvalid formid="generatePlan" action="zyInspectionPlanController.do?doAdd&zyIpId=${zyIP.id}" dialog="false" layout="" callback="callback" tiptype="3">
<input type="hidden" value="${zyEquipmentSparePage.id }" name="equipmentIds" />
<input type="hidden" value="${parentId }" name="parentId"/>
<div class="subtitle">
	<p>设备信息</p>
	<table class="nobordertable noborder">
		<tr>
			<td class="leftgrid">
				<label>设备SN:</label>
			</td>
			<td>
				<span>${zyEquipmentSparePage.sn }</span>
			</td>
			<td class="leftgrid">
				<label>设备型号:</label>
			</td>
			<td>
				<span>${zyEquipmentSparePage.type.typeDesc }</span>
			</td>
		</tr>
		<tr>
			<td class="leftgrid">
				<label>BP:</label>
			</td>
			<td>
				<span>${zyEquipmentSparePage.bpNo }</span>
			</td>
			<td class="leftgrid">
				<label>安装日期:</label>
			</td>
			<td>
				<span><fmt:formatDate  value="${zyEquipmentSparePage.installDate }" type="both" pattern="yyyy-MM-dd" /></span>
			</td>
		</tr>
		<tr>
			<td class="leftgrid">
				<label>保修期:</label>
			</td>
			<td>
				<span><fmt:formatDate  value="${zyEquipmentSparePage.baseRepairDate }" type="both" pattern="yyyy-MM-dd" /></span>
			</td>
			<td class="leftgrid">
				<label>保修截止日期:</label>
			</td>
			<td>
				<span><fmt:formatDate  value="${zyEquipmentSparePage.repairEndDate }" type="both" pattern="yyyy-MM-dd" /></span>
			</td>
		</tr>
		<tr>
			<td class="leftgrid">
				<label>影院名称:</label>
			</td>
			<td>
				<span>${zyEquipmentSparePage.zyCinema.name }</span>
			</td>
			<td class="leftgrid">
				<label>影院地址:</label>
			</td>
			<td>
				<span>${zyEquipmentSparePage.zyCinema.address }</span>
			</td>
		</tr>
		<tr>
			<td class="leftgrid">
				<label>影院所属省市:</label>
			</td>
			<td>
				<span>${zyEquipmentSparePage.tsTerritory.TSTerritory.territoryName } - ${zyEquipmentSparePage.tsTerritory.territoryName}</span>
			</td>
			<td class="leftgrid">
				<label>去年巡检日期:</label>
			</td>
			<td>
				<span><fmt:formatDate  value="${zyEquipmentSparePage.lastYearInspectionDate }" type="both" pattern="yyyy-MM-dd" /></span>
			</td>
		</tr>
		<tr>
			<td class="leftgrid">
				<label>所在厅:</label>
			</td>
			<td>
				<span>${zyEquipmentSparePage.house.roomNum }</span>
			</td>
			<td></td>
			<td></td>
		</tr>
	</table>
</div>
<div class="subtitle">
	<p>巡检计划信息</p>
	<table class="nobordertable noborder">
		<tr>
			<td class="leftgrid">
				<label>计划巡检月份:</label>
			</td>
			<td>
				<input type="hidden" name="processsId" value="${zyIP.processsId }" />
				<%--<span><t:dictSelect field="planQuarter" typeGroupCode="<%=StaticValue.DIC_PLAN_INSPECTION_QUARTER %>" hasPleaseSelect="fales" defaultVal="${zyIP.planQuarter }" /></span>--%>
				<span><t:dictSelect field="ipMonth" typeGroupCode="<%=StaticValue.DIC_IP_MONTH %>" hasPleaseSelect="fales" defaultVal="${zyIP.ipMonth }" /></span>
			</td>
			<td class="leftgrid">
				<label>巡检单位:</label>
			</td>
			<td>
				<span>
					<select name="company" id="company">
						<option value="">---请选择--- </option>
						<c:forEach items="${tsDeparts }" var="depart">
							<option value="${depart.orgCode }" <c:if test="${!empty zyIP && zyIP.company eq depart.orgCode }">selected='selected'</c:if>>${depart.shortname }</option>
						</c:forEach>
					</select>
				</span>
			</td>
		</tr>
		<tr>
			<td class="leftgrid">
				<label>光路要求:</label>
			</td>
			<td>
				<span><t:dictSelect field="lightPath" typeGroupCode="<%=StaticValue.DIC_LIGHT_PATH %>" hasPleaseSelect="fales" defaultVal="${zyIP.lightPath }"/></span>
			</td>
			<td class="leftgrid">
				<label>巡检负责人:</label>
			</td>
			<td>
				<input name="contacter.id" type="hidden" id="contacterId" value="${zyIP.contacter.id}"/>
				<input name="name" class="inputxt" id="contacterName" value="${zyIP.contacter.name}" readonly="readonly" datatype="*" nullmsg="当前巡检单位巡检负责人为空，请重新选择"/>
			</td>
		</tr>
		<tr>
			<td class="leftgrid">
				<label>巡检负责人电话:</label>
			</td>
			<td>
				<span id="contacterCellPhone">${zyIP.contacter.cellphone1 }${!empty zyIP.contacter.cellphone1 && !empty zyIP.contacter.cellphone2 ? '/' : ""}${zyIP.contacter.cellphone2 }</span>
			</td>
			<td class="leftgrid">
				<label>巡检负责人邮箱:</label>
			</td>
			<td>
				<span id="contacterEmail">${zyIP.contacter.email}</span>
			</td>
		</tr>
		<tr>
			<td class="leftgrid">
				<label>其他要求:</label>
			</td>
			<td>
				<span><textarea name="remarks" rows="6" cols="50" maxlength="500" datatype="*1-500">${zyIP.remarks }</textarea></span>
			</td>
			<td>
				<label></label>
			</td>
			<td>
				<span></span>
			</td>
		</tr>
		<tr>
			<td colspan="4" style="text-align: center;">
				<a href="#" class="easyui-linkbutton" id="subForm">保存</a>
				<c:if test="${!empty zyIP.state && btnCanCancel }"><a href="#" class="easyui-linkbutton" id="cancelPlan">取消巡检计划</a></c:if> 
			</td>
		</tr>
	</table>
</div>
</t:formvalid>
</body>
